home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6066 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: ix.netcom.com!netnews
  2. From: miker3@ix.netcom.com (Mike Rubenstein)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Memory allocation.
  5. Date: Sun, 11 Feb 1996 14:01:12 GMT
  6. Organization: Netcom
  7. Message-ID: <311df641.156228704@nntp.ix.netcom.com>
  8. References: <1996Feb10.161530.26449@wisipc.weizmann.ac.il> <00001a81+00009e86@msn.com>
  9. NNTP-Posting-Host: ix-dc12-11.ix.netcom.com
  10. X-NETCOM-Date: Sun Feb 11  6:00:42 AM PST 1996
  11. X-Newsreader: Forte Agent .99d/32.182
  12.  
  13. Tendrils@msn.com (kelvin  ) wrote:
  14.  
  15. > The program may or may not works...
  16. > try adding another function call in main()...before cout.
  17. > e.g.
  18. > int func2(int input)
  19. > {
  20. >     return input;
  21. > }
  22. > int
  23. > main()
  24. > {
  25. >     int* x=func();
  26. >     int y=func2(22); // add this!!!
  27. >     cout<<x[2]<<endl;
  28. >     return(1);
  29. > }
  30.  
  31. Which may or may not work.  Adding the new function has nothing to do
  32. with the problem in the original that func() was returning a pointer
  33. to an auto that was deallocated when func() returned.
  34.  
  35. Is it really necessary to post this kind of nonsense?
  36.  
  37.  
  38. Michael M Rubenstein
  39.